//
//  FogetPassWordController.m
//  敢唆嘛!
//
//  Created by lanou on 15/11/24.
//  Copyright © 2015年 zms. All rights reserved.
//

#import "FogetPassWordController.h"
#import "Device.h"
#import "Define.h"
@interface FogetPassWordController ()

@property (nonatomic,retain)UITextField *emailText; //填写注册的邮箱
@end

@implementation FogetPassWordController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    self.view.backgroundColor = [UIColor whiteColor];
    
    // 创建左上角返回按钮
    UIButton *backBtn = [UIButton buttonWithType:UIButtonTypeCustom];
    backBtn.frame = CGRectMake(0, 0, KSWidth / 18, KSWidth / 18);
    [backBtn setImage:[UIImage imageNamed:@"iconfont-unie61e"] forState:UIControlStateNormal];
    [backBtn addTarget:self action:@selector(backBtnAction:) forControlEvents:UIControlEventTouchUpInside];
    UIBarButtonItem *leftBackBtn = [[UIBarButtonItem alloc] initWithCustomView:backBtn];
    self.navigationItem.leftBarButtonItem = leftBackBtn;
    
    self.navigationItem.title = @"重置密码";
    
    self.navigationController.navigationBar.translucent = NO;
    
    self.emailText = [[UITextField alloc]initWithFrame:CGRectMake(0, 200, KSWidth/4*3, 30)];
    
    self.emailText.placeholder = @"请输入邮箱";
    
    self.emailText.center =  CGPointMake(KSWidth/2, KSHeight/6);
    
    [self.view addSubview:_emailText];
    
    //在textField添加一条白线
    UIView *lineView = [[UIView alloc]initWithFrame:CGRectMake(0, 200, KSWidth/4*3, 1)];
    
    lineView.center = CGPointMake(KSWidth/2, KSHeight/6+20);
    
    lineView.backgroundColor = [UIColor colorWithRed:150 / 255.0 green:150 / 255.0 blue:150 / 255.0 alpha:1.0];
    
    [self.view addSubview:lineView];
    
    //重置密码按钮
    UIButton *newButton = [UIButton buttonWithType:UIButtonTypeSystem];
    
    newButton.frame = CGRectMake(0, 0, KSWidth/3, KSWidth/8);
    
    newButton.center = CGPointMake(KSWidth/2, KSHeight/3);
    
    newButton.layer.borderColor = [UIColor colorWithRed:220 / 255.0 green:220 / 255.0 blue:220 / 255.0 alpha:1.0].CGColor;
    
    [newButton.layer setCornerRadius:10];
    
    newButton.layer.borderWidth = 1;
    
    [newButton setTitle:@"邮箱重置密码" forState:UIControlStateNormal];
    
    [newButton addTarget:self action:@selector(newButtonAction:) forControlEvents:UIControlEventTouchUpInside];
    
    [self.view addSubview:newButton];
    
    

    
}

// 返回按钮触发
- (void)backBtnAction:(UIButton *)backBtn
{
    [self.navigationController popViewControllerAnimated:YES];
}

#pragma mark --重置密码按钮触发的事件 --
-(void)newButtonAction:(UIButton *)btn{
    
    //bmob会发邮件给你的邮箱 会出现一个新密码
    [BmobUser requestPasswordResetInBackgroundWithEmail:self.emailText.text];
    
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
